package com.cv.platform.controller.platform.favourite;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.pojo.Result;
import com.cv.platform.controller.platform.favourite.vo.CvVideoFavouriteRespVO;
import com.cv.platform.controller.platform.favourite.vo.CvVideoFavouriteSaveReqVO;
import com.cv.platform.controller.platform.favourite.vo.CvVideoFavouriteReqVO;
import com.cv.platform.service.favourite.CvVideoFavouriteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 视频平台 - 视频收藏控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频收藏控制层")
@RestController
@RequestMapping("/platform/video/favourite")
public class CvVideoFavouriteController {

    @Resource
    private CvVideoFavouriteService cvVideoFavouriteService;

    @GetMapping("isFavourite")
    @Operation(summary = "判断视频是否被收藏")
    public Result<Boolean> isFavourite(Long videoId) {
        return Result.success(cvVideoFavouriteService.getIsVideoFavourite(videoId));
    }

    @PostMapping("save")
    @Operation(summary = "保存视频收藏")
    public Result<Void> saveFavourite(@RequestBody CvVideoFavouriteSaveReqVO reqVO) {
        cvVideoFavouriteService.saveVideoFavourite(reqVO);
        return Result.success();
    }

    @DeleteMapping("cancel")
    @Operation(summary = "取消收藏视频")
    public Result<Void> deleteFavourite(Long videoId) {
        cvVideoFavouriteService.deleteVideoFavourite(videoId);
        return Result.success();
    }

    @GetMapping("page")
    @Operation(summary = "视频收藏分页数据")
    public Result<PageResult<CvVideoFavouriteRespVO>> getFavouritePage(CvVideoFavouriteReqVO reqVO) {
        return Result.success(cvVideoFavouriteService.getVideoFavouritePage(reqVO));
    }

}
